<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
      //1.无返回值
      function qiuhe(a,b){
         var he = a + b;
         console.log("两数之和：" +he); //7
      }
      qiuhe(3,4);

      //2.有返回值
      function qiuhe1(a,b){
        var he = a + b;
        return "两数之和：" +he;
      }
      var s = qiuhe1(5,6);
      console.log(s);  //11

      //3.参数对象
      function func(a,b,c){
          console.log( arguments.length ); //3,获得参数的个数
          console.log( arguments[1] ); //4,获得下标为1的参数
      }
      func(3,4,5);

      //4. 构造函数
      var myFunction = new Function("a","b","return a * b");
      var x = myFunction(4,3);
      console.log(x); //12

      //5.匿名函数(没有名称的函数)
      var fn = function(a,b){// 没有名字的函数，应该用一个变量来接收
          return a *10 + b;
      }
      console.log(fn(3,4)); //34

      //6. 全局函数
      //6.1: isNaN：检查其参数是否是非数字值
      console.log( isNaN(123) );    //数字,false
      console.log( isNaN("hello") ); //非数字,true
      console.log( isNaN(4-1) );   //数字,false
      console.log( isNaN(123) );   //数字,false
      console.log( isNaN(-20) );   //数字,false
      console.log( isNaN("123") ); //数字,false
      console.log( isNaN("1a123") ); //非数字,true

      //6.2: eval：用来转换字符串中的运算
      var str = "1 + 3";
      console.log(str); //1 + 3, +会认定为一种字符符号而已，没有加法的作用
      console.log(eval(str)); //4, 让字符串中的运算符号“+”生效

      //6.3: encodeURI 与 decodeURI
      var name = "拉勾网";
      console.log("转码前："+ name); //拉勾网

      name = encodeURI(name);
      console.log("转码后："+ name); //%E6%8B%89%E5%8B%BE%E7%BD%91

      name = decodeURI(name);
      console.log("解码后："+ name); //拉勾网
      


    </script>
</body>
</html>